#tag Class
Protected Class UpdaterSocket
Inherits IPCSocket
	#tag Event
		Sub DataAvailable()
		  ParseData(me.ReadAll)
		End Sub
	#tag EndEvent


	#tag Method, Flags = &h0
		Sub ParseData(s as string)
		  dim s1,s2,m as string
		  
		  s1=NthField(s,CHR(31),1)
		  s2=NthField(s,CHR(31),2)
		  
		  SELECT CASE s1
		    
		  CASE "1000" 'connect ok
		    
		    m=ConvertEncoding("2000"+CHR(31)+format(app.MajorVersion,"00")+format(app.MinorVersion,"00")+format(app.NonReleaseVersion,"0000"),Encodings.ASCII)
		    
		    me.write(m)
		    
		    DelayMBS 1
		    
		    m=ConvertEncoding("2010"+CHR(31)+app.ExecutableFile.absolutepath,Encodings.ASCII)
		    
		    me.write (m)
		    
		    DelayMBS 1
		    
		    m=convertencoding("2020"+CHR(31)+"http://www.openonair.com/libraryplayer/updroot/manifest.upml",Encodings.ASCII)
		    
		    me.write(m)
		    
		  CASE "9000" 'quit application for update
		    
		    QuitApplication
		    
		  END SELECT
		  
		End Sub
	#tag EndMethod


	#tag Hook, Flags = &h0
		Event QuitApplication()
	#tag EndHook


	#tag ViewBehavior
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			Type="Integer"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			Type="Integer"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Path"
			Visible=true
			Group="Behavior"
			Type="String"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			Type="Integer"
			InheritedFrom="IPCSocket"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
